﻿using FinScreen.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FinScreen.Util;
using System.ComponentModel.DataAnnotations;

namespace FinScreen.ViewModel
{
    class DisplayInstrument
    {
        [DisplayName("代码")]
        public string Code { get; set; }
        [DisplayName("名称")]
        public string Name { get; set; }

        [DisplayName("当前价")]
        public double MarketPrice { get; set; }
        [DisplayName("涨跌%")]
        public double PctChange { get; set; }
        [DisplayName("涨跌")]
        public double NetChange { get; set; }

        [DisplayName("行业")]
        public string Industry { get; set; }
        [DisplayName("市盈率")]
        public double? PEG { get; set; }

        [DisplayName("今开")]
        public double Open { get; set; }
        [DisplayName("最高")]
        public double High { get; set; }
        [DisplayName("最低")]
        public double Low { get; set; }
        [DisplayName("昨收")]
        public double? PrevClose { get; set; }
        [DisplayName("收盘")]
        public double Close { get; set; }
        [DisplayName("成交量")]
        public double Volume { get; set; }
        [DisplayName("成交额")]
        public double TurnOver { get; set; }

        [DisplayName("时间")]
        public DateTime TS { get; set; }

        public DisplayInstrument()
        {

        }
        public DisplayInstrument(Instrument instrument)
        {
            this.MergeProperties(instrument);

            NetChange = Math.Round(NetChange, 2);
            PctChange = Math.Round(PctChange, 1);

            MarketPrice = instrument.LastPrice;
        }
    }
}
